package com.miyuan.wm.controller;

import com.alibaba.fastjson.JSON;
import com.miyuan.wm.request.QueryAccessRecordsRequestVo;
import com.miyuan.wm.request.QueryUserOperationLogsRequestVo;
import com.miyuan.wm.response.PageResponse;
import com.miyuan.wm.response.QueryAccessRecordsResponseVo;
import com.miyuan.wm.response.QueryUserOperationLogsResponseVo;
import com.miyuan.wm.service.SystemLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * @ClassName LogController
 * @Description 日志管理控制器
 */
@RestController
@Api(description = "日志管理控制器", tags = {"日志管理"})
@RequestMapping(value = "/log")
@Slf4j
public class LogController {

    @Autowired
    private SystemLogService systemLogService;

    @ApiOperation(value = "获取系统登入登出日志接口")
    @PostMapping("/getUserLog")
    public PageResponse<List<QueryAccessRecordsResponseVo>> listUserLog(@Valid @RequestBody QueryAccessRecordsRequestVo requestVo) {
        log.info("查询系统登入登出操作日志请求参数：{}", JSON.toJSONString(requestVo));
        return systemLogService.listAccessRecordsLog(requestVo);
    }

    @ApiOperation(value = "获取用户操作日志接口")
    @PostMapping("/getUserOperationLog")
    public PageResponse<List<QueryUserOperationLogsResponseVo>> listUserOperationLog(@Valid @RequestBody QueryUserOperationLogsRequestVo requestVo) {
        log.info("查询系统登入登出操作日志请求参数：{}", JSON.toJSONString(requestVo));
        return systemLogService.listUserOperationLog(requestVo);
    }

}
